/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import GUI.DatabaseHandler;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author Neno
 */
public class LabelFrame extends JFrame implements ActionListener{
    private JLabel label1;
    private JLabel label2;
    private JLabel label4;
    private JLabel label6;
 
    private final Font font = new Font("Constantia",1,22);
    private final Font font2 = new Font("Constantia",1,35);
    public LabelFrame(){
        super("Cashadin!");
        
        JPanel panel = new JPanel();
        GridBagLayout grid = new GridBagLayout();
        //this.getContentPane().add(panel,BorderLayout.NORTH);
        panel.setLayout(grid);
        GridBagConstraints c = new GridBagConstraints();
        
        label1 = new JLabel("JJCHN ATM Machine");
        label1.setFont(font2);
        add(label1);
        c.gridx = 0;
        c.gridy = 0;
        panel.add(label1, c);
        
        label2 = new JLabel("User name: ");
        label2.setFont(font);
        c.gridx = 0;
        c.gridy = 1;
        c.insets = new Insets(10,10,10,10);
        panel.add(label2,c);
        final JTextField text1 = new JTextField(20);
        //label3 = new JLabel("text");
        c.gridx = 1;
        c.gridy = 1;
        
        panel.add(text1,c);
        label4 = new JLabel("Password: ");
        label4.setFont(font);
        c.gridx = 0;
        c.gridy = 2;
        
        panel.add(label4,c);
       // label5 = new JLabel("text");
        final JPasswordField text2 = new JPasswordField(20);
        c.gridx = 1;
        c.gridy = 2;
        panel.add(text2,c);
        
          
//          label6 = new JLabel("Country: ");
//        label6.setFont(font);
//        c.gridx = 0;
//        c.gridy = 3;
//        panel.add(label6,c);
//      //  label7 = new JLabel("text");
//        JTextField text3 = new JTextField("Sweden", 20);
//        
//        c.gridx = 1;
//        c.gridy = 3;
//        panel.add(text3,c);
//        
        //JLabel attendents = new JLabel("Attendent: ");
        //attendents.setFont(font);
        //c.gridx = 0;
        //c.gridy = 4;
        //panel.add(attendents, c);
        //JComboBox options = new JComboBox();
        //options.insertItemAt("Lisa Petterson", 0);
        //options.insertItemAt("Caroline Ericsson", 1);
        //options.insertItemAt("Lisa  Isaksson", 2);
        //c.gridx = 1;
        //c.gridy = 4;
        //panel.add(options,c);
        JButton buttonOK = new JButton("Login");
        c.gridx = 7;
        c.gridy = 7;

        panel.add(buttonOK, c);
        buttonOK.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent arg0){
                String user = text1.toString();
                String url = "jdbc:mysql://localhost:3306/bankapp";
                DatabaseHandler dbh = new DatabaseHandler(url, "root", "tyringe1");
                String compPass = dbh.comparePassword(user);
                if(text2.toString() == compPass){
                    System.out.println("We have a compare!");
                }
            }
        });
        
        add(panel);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
